﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="DashboardDocument.cs" company="Concept Architecture">
//   (c) 2010 Muhammad Umer Farooq
// </copyright>
// <summary>
//   Defines the <seealso cref="Hisaab.Windows.Client.Documents.DashboardDocument" /> type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Hisaab.Windows.Client.Documents
{
    using System;
    using System.Diagnostics.Contracts;
    using Common;
    using View;
    using ViewModel;

    /// <summary>
    /// Defines the <seealso cref="Hisaab.Windows.Client.Documents.DashboardDocument"/> type.
    /// </summary>
    public class DashboardDocument : Document
    {
        /// <summary>
        /// Vehicle view model
        /// </summary>
        private readonly DashboardViewModel _viewModel;

        /// <summary>
        /// Initializes a new instance of the <see cref="DashboardDocument"/> class.
        /// </summary>
        /// <param name="viewModel">The view model.</param>
        public DashboardDocument(DashboardViewModel viewModel)
            : base("Dashboard")
        {
            Contract.Requires<ArgumentNullException>(viewModel != null);
            _viewModel = viewModel;
            View = new DashboardView { DataContext = _viewModel };

            DashboardViewModel.RefreshCommand.RegisterPotentialTarget(View.ActiveAwareness, _viewModel.Refresh);
        }

        /// <summary>
        /// Documents the closed.
        /// </summary>
        public override void DocumentClosed()
        {
            DashboardViewModel.RefreshCommand.UnregisterPotentialTarget(View.ActiveAwareness);
        }
    }
}